<?php

namespace RPPrincipal\SintysBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use RPPrincipal\SintysBundle\Entity\Personas;

/**
 * Personas controller.
 *
 * @Route("/sintys")
 */
class PersonasController extends Controller {

    /**
     * Lists all Personas entities.
     *
     * @Route("/", name="sintys")
     * @Method("GET")
     * @Template()
     */
    public function indexAction() {
        $em = $this->getDoctrine()->getManager('sintys');

        //$entities = $em->getRepository('SintysBundle:Personas')->findAll();
        $entities = $em->getRepository('SintysBundle:Personas')->findBy(
                   array('nombre' => ''),        // $where 
                   array('id' => 'ASC'),    // $orderBy
                   10,                        // $limit
                   0                          // $offset
                 );
        
        return array(
            'entities' => $entities,
        );
    }

    /**
     * Finds and displays a Personas entity.
     *
     * @Route("/{id}", name="sintys_show")
     * @Method("GET")
     * @Template()
     */
    public function showAction($id) {
        $em = $this->getDoctrine()->getManager('sintys');

        $entity = $em->getRepository('SintysBundle:Personas')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Personas entity.');
        }

        return array(
            'entity' => $entity,
        );
    }

}
